package com.data.center.dictionary;

import com.data.center.exception.exception.BizException;
import com.data.center.exception.info.CommonEnum;

/**
 * @author DN
 * @description:实名认证状态代码映射枚举类
 * @date 2023/12/4 18:00
 */
public enum AuthenticationType implements KeyValueMap {
    BUSINESS_TWO_ELEMENT("01", "业务二要素认证"),
    PUBLIC_SECURITY_TWO_ELEMENT("02", "公安部二要素认证"),
    BUSINESS_THREE_ELEMENT("11", "业务三要素认证"),
    PUBLIC_SECURITY_THREE_ELEMENT("12", "公安部三要素认证");

    private String code;
    private String name;

    AuthenticationType(String code, String name) {
        this.code = code;
        this.name = name;
    }

    @Override
    public String getKey() {
        return code;
    }

    @Override
    public String getValue() {
        return name;
    }

    public static AuthenticationType getValueByKey(String key) {
        for (AuthenticationType authenticationType : values()) {
            if (authenticationType.code.equals(key)) {
                return authenticationType;
            }
        }
        throw new BizException(CommonEnum.CAN_NOT_FIND_IN_DICTIONARY);
    }

    public static AuthenticationType getKeyByValue(String value) {
        for (AuthenticationType authenticationType : values()) {
            if (authenticationType.name.equals(value)) {
                return authenticationType;
            }
        }
        throw new BizException(CommonEnum.CAN_NOT_FIND_IN_DICTIONARY);
    }
}
